<?php

include "../functions.php";
//编辑
//一、获得旧内容****************
//1.引入数据库
$data = include "./data.php";
//2.获得下标
$id = (int)$_GET['id'];
//3.获得旧内容
$oldData = $data[$id];
//二、完成修改********************
if(IS_POST){
	//所谓的修改，就是覆盖原来的
	$data[$id] = $_POST;
	//写入数据库
	data_to_file($data, './data.php');	
	cheng('编辑成功', './liuyan.php');
}


?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
	<title>编辑</title>
<style type="text/css">
    *{
    	padding: 0;
    	margin: 0;
    }
    body{
    	background: url(images/vv.jpg);
    }
	div.write{
      width: 400px;
      height: 300px;
      /*position: relative;
      top:105px;left:0px;*/
      background: url(images/write.jpg) no-repeat 0px -150px;
      border: solid 2px #DA4100;
      border-radius: 5%;
      margin: 100px auto;
      position:relative;
      /*display: none;*/
      /*z-index: 3;*/ 
     }
     div.write .cat{
      width: 75px;
      height: 45px;
      position: absolute;
      top: -47px;left: 60px;
      background: url(images/cat.png);
     }
     div.write h4.name{
     	margin-top: 10px;
     	margin-left: 10px;
     	display: block;
     	/*width: 80px;
     	height: 20px;*/
     	float: left;
     }
     div.write h4.content{
     	margin-top: 10px;
     	margin-left: 10px;
     	display: block;
     	float: left;
     }
     div.write input.name{
     	margin-top: 10px;
     	margin-left: 0px;
     	float: left;
     	
     	border: solid 1px #000;
     	background: url(images/write.jpg) no-repeat 0px -80px;
     }
     div.write .nei{
     	margin-top: 10px;
     	width: 260px;
     	height: 180px;
     	border: solid 1px #000;
     	background: rgba(0,0,0,0);
     }
     div.write .tijiao{
     	background: url(images/vv.jpg);
     	font-size: 14px;
     	font-family: 微软雅黑;
     	font-weight: 400;
     	border-radius: 20px;
     	margin-top: 20px;
     	margin-left: 150px;
     	border: solid 1px #582F1D;
     	cursor: pointer;
     }
    
    
    
</style>
</head>
<body>
	<div class="write">
       <div class="cat"></div>
       <h4 class="name">您的昵称:</h4>
       <form action="" method="post">
       	   <input type="text" class="name" name="nicheng" value="<?php echo $oldData['nicheng']; ?>"/>
       	   <br></br>
       	   <h4 class="content">您的留言:</h4>
       	   <textarea name="c" id="" class="nei" cols="30" rows="10"><?php echo $oldData['c']; ?></textarea>
       	   <input class="tijiao" type="submit" value="我真的改好了!" />  
       </form>
    </div>
   
</body>
</html>